<script setup lang="ts">
import { reactive, ref } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    code: "",
    name: "",
    sort: null,
    note: "",
    userid: null
  }),
  userSelect: []
});

const ruleFormRef = ref();
const newFormInline = ref<any>(props.formInline);
const userSelect = ref<any>(props.userSelect);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form ref="ruleFormRef" :model="newFormInline" :rules="formRules" label-width="60px">
    <el-row :gutter="30">
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="编码" prop="code">
          <el-input v-model="newFormInline.code" clearable placeholder="请输入编码" />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="名称" prop="name">
          <el-input v-model="newFormInline.name" clearable placeholder="请输入名称" />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="排序" prop="sort">
          <el-input-number v-model="newFormInline.sort" :min="0" :max="9999" controls-position="right" />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="管理员" prop="userid">
          <el-select v-model="newFormInline.userid" multiple placeholder="请选择管理员" style="width:100%">
            <el-option v-for="item in userSelect" :key="item.Id" :label="item.RealName" :value="item.Id" />
          </el-select>
        </el-form-item>
      </re-col>
      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="备注" prop="note">
          <el-input v-model="newFormInline.note" clearable placeholder="请输入备注" type="textarea" />
        </el-form-item>
      </re-col>
    </el-row>
  </el-form>
</template>

<style lang="scss" scoped>
.el-radio {
  margin-right: 16px;
}
</style>
